CPP=g++
#CPPFLAGS=-Wall -g3
#CPPFLAGS=-Wall -O3 -DDEBUG
CPPFLAGS=-Wall -O9

OBJECTS=point.o supowit.o utils.o naive_chains.o search.o untangling.o

BINDIR=./

%.o: %.cpp
	@echo " [C++] Compiling $<"
	@$(CPP) $(CPPFLAGS) -c $< -o $@

all: info $(OBJECTS)
	@echo " [LNK] Linking partition"
	@$(CPP) $(CPPFLAGS) -o $(BINDIR)/partition partition.cpp $(OBJECTS)
	@echo " [LNK] Linking partition_greedy"
	@$(CPP) $(CPPFLAGS) -o $(BINDIR)/partition_greedy partition_greedy.cpp $(OBJECTS) 
	@echo " [LNK] Linking build_index"
	@$(CPP) $(CPPFLAGS) -o $(BINDIR)/build_index build_index.cpp $(OBJECTS) 
	@echo " [LNK] Linking time_chains_naive"
	@$(CPP) $(CPPFLAGS) -o $(BINDIR)/time_chains_naive time_chains_naive.cpp $(OBJECTS) -frounding-math 
	@echo " [LNK] Linking time_chains"
	@$(CPP) $(CPPFLAGS) -o $(BINDIR)/time_chains time_chains.cpp $(OBJECTS) -frounding-math 
	@echo " [LNK] Linking time_chains_adaptive"
	@$(CPP) $(CPPFLAGS) -o $(BINDIR)/time_chains_adaptive time_chains_adaptive.cpp $(OBJECTS) -frounding-math 


info:
	@echo " [MSG] COMPILER = $(CPP)"
	@echo " [MSG] FLAGS = $(CPPFLAGS)"

clean:
	@echo " [CLN] Cleaning object files"
	@rm -f $(OBJECTS)
	@echo " [CLN] Removing binaries"
	@rm -f $(BINDIR)/partition
	@rm -f $(BINDIR)/partition_greedy
	@rm -f $(BINDIR)/build_index
	@rm -f $(BINDIR)/test_naive_chains
	@rm -f $(BINDIR)/get_statistics
	@rm -f $(BINDIR)/time_chains
	@rm -f $(BINDIR)/time_chains_naive
	@rm -f $(BINDIR)/time_chains_adaptive
	@rm -f $(BINDIR)/time_kdtree
	@rm -f $(BINDIR)/time_range_tree
	@rm -f $(BINDIR)/validate
	

kdtree:
	@echo " [LNK] Linking time_kdtree"
	@$(CPP) -o $(BINDIR)/time_kdtree time_kdtree.cpp -lCGAL -frounding-math -O9 -Wall

rangetree:
	@echo " [LNK] Linking time_range_tree"
	@$(CPP) -o $(BINDIR)/time_range_tree time_range_tree.cpp -lCGAL -frounding-math -O9 -Wall
